package main

import (
	"github.com/gin-gonic/gin"
	"http_server/src/controller"
	"http_server/src/interceptor"
	"http_server/src/services"
)

func main() {

	router := gin.Default()

	userService := services.NewUserService()
	userController := controller.NewUserController(userService)

	publicRouter := router.Group("/user")
	{
		publicRouter.POST("/login", userController.Login)
	}

	protectedRouter := router.Group("/user")
	protectedRouter.Use(interceptor.AuthMiddleware())
	{
		protectedRouter.POST("/updateUserMessage", userController.UpdateUserMessage)
		protectedRouter.GET("/getUserMessage/:username", userController.GetUserMessage)
	}

	// 设置服务器监听地址
	addr := ":8080"
	router.Run(addr)
}
